//
//  DiscoverViewController.swift
//  SinaWeibo
//
//  Created by celeste on 16/5/10.
//  Copyright © 2016年 celeste. All rights reserved.
//

import UIKit

private let LDDiscoverID = "LDDiscoverID"

/// 发现控制器
class DiscoverViewController: RootViewController {

    override func viewDidLoad() {
        
        setupRefreshControl()
        
        super.viewDidLoad()

        tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: LDDiscoverID)
        // 设置访客视图
        visitorView?.setupInfo("visitordiscover_image_message",
            message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
    }

    override func loadData() {
        
        refreshControl?.beginRefreshing()
        
        let when = dispatch_time(DISPATCH_TIME_NOW, Int64(Double(NSEC_PER_SEC) * 1.0))
        
        dispatch_after(when, dispatch_get_main_queue()) { () -> Void in
            
            self.dataCount += 10
            
            self.refreshControl?.endRefreshing()
            
            
            self.tableView?.reloadData()
            
            
        }
        

    }
    // MARK : - 私有属性
    private var dataCount = 0
    
}

// MARK : - 数据源方法

extension DiscoverViewController {

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return dataCount
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCellWithIdentifier(LDDiscoverID, forIndexPath: indexPath)
        
        cell.textLabel?.text = "\(indexPath.row)"
        
        return cell
    }



}